package flexo.examples;

import flexo.graphic.Color;
import flexo.math.*;

public class Test_Graphic_MultipleCameras extends Test_Graphic_Base
{
	flexo.scene.Node root;
	
	public static void main(String[] args)
	{
		run("flexo.examples.Test_Graphic_MultipleCameras");
	}
	
	public void init()
	{
		super.init();
		root = mainScene.addChild("root");		
		
		flexo.graphic.Material mat = graphic.addMaterial("default", "default");
		flexo.graphic.ShaderParam pTex = mat.getShaderParam("tex");
		pTex.setValue("textures/maptexture.jpg");
		
		flexo.graphic.entity.Entity terrain = graphic.addTerrain("textures/height.jpg", new Coords(6,6), new Coords(50,50), 3.0f);		
		terrain.setMaterial("default");
		root.setPosition(new Vector(0,0,0));
		terrain.attachTo(root);
				
		flexo.graphic.Camera cam2 = graphic.addCamera3D("mainScene");
		cam2.setPositionNode(this.camPosNode);
		cam2.setTargetNode(root);
		cam2.setViewport(0.7f, 1.0f);
		cam2.setBackgroundColor(new Color(1,0,0,1));
	}

	public void cleanUp()
	{		
	}	

	public void update()
	{
		Quaternion rotation = Quaternion.getTempQuaterion();
		rotation.fromAxis(new flexo.math.Vector(0,1,0), getElapsedTime() * 20);
		root.rotate(rotation);
	}
}
